function stringContains(string, value) {
    return string.indexOf(value) != -1;
}

Object.defineProperty(Object.prototype, "setValueForKey", {
    value: function (value, key) {
        this[key] = value;
    }
});

Object.defineProperty(Object.prototype, "setValueForKeyPath", {
    value: function (value, keyPath) {
        if (keyPath == null) return;
        if (stringContains(keyPath, '.') == false) {
            this.setValueForKey(value, keyPath);
            return;
        }

        var chain = keyPath.split('.');
        var firstKey = chain.shift();
        var shiftedKeyPath = chain.join('.');

        this[firstKey].setValueForKeyPath(value, shiftedKeyPath);
    }
});

Object.defineProperty(Object.prototype, "getValueForKey", {
    value: function (key) {
        return this[key];
    }
});

Object.defineProperty(Object.prototype, "getValueForKeyPath", {
    value: function (keyPath) {
        if (keyPath == null) return;
        if (stringContains(keyPath, '.') == false) {
            return this.getValueForKey(keyPath);
        }

        var chain = keyPath.split('.');
        var firstKey = chain.shift();
        var shiftedKeyPath = chain.join('.');

        return this[firstKey].getValueForKeyPath(shiftedKeyPath);
    }
});

